﻿using System.Collections.Generic;

namespace MathExpression
{
    public class ExpressionFactory
    {
        public static IMathExpression Create(double value)
        {
            return CreateScalar(value);
        }

        public static IMathExpression Create(double freeValue, double parameter, string variable = "x")
        {
            return CreatePolynomial(freeValue, parameter, variable);
        }

        public static IMathExpression Create(IEnumerable<IMathExpression> values, string variable = "x")
        {
            return CreatePolynomial(values, variable);
        }

        public static IMathExpression Create(IMathExpression nominator, IMathExpression denominator)
        {
            return null;
        }

        private static IMathExpression CreateScalar(double value)
        {
            return new Scalar(value);
        }

        private static IMathExpression CreatePolynomial(IEnumerable<IMathExpression> polynom, string variable = "x")
        {
            return new Polynomial(polynom, variable);
        }

        private static IMathExpression CreatePolynomial(double freeValue, double parameter, string variable)
        {
            return new Polynomial(freeValue, parameter, variable);
        }
    }
}
